var elixir = require('laravel-elixir');
var gulp = require('gulp');
var rename = require('gulp-rename');

gulp.task("copyfiles", function () {
    // jquery.js
    gulp.src('vendor/bower_dl/jquery/dist/jquery.js')
        .pipe(gulp.dest("resources/assets/js/"));

    // less
    gulp.src('vendor/bower_dl/bootstrap/less/**')
        .pipe(gulp.dest("resources/assets/less/bootstrap/"));

    // bootstrap.js
    gulp.src('vendor/bower_dl/bootstrap/dist/js/bootstrap.js')
        .pipe(gulp.dest("resources/assets/js/"));

    // fonts
    gulp.src("vendor/bower_dl/bootstrap/dist/fonts/**")
        .pipe(gulp.dest("public/assets/fonts/"));

    gulp.src("vendor/bower_dl/font-awesome/less/**")
        .pipe(gulp.dest("resources/assets/less/fontawesome"));

    gulp.src("vendor/bower_dl/font-awesome/fonts/**")
        .pipe(gulp.dest("public/assets/fonts"));

    gulp.src("vendor/bower_dl/datatables/media/js/jquery.dataTables.js")
        .pipe(gulp.dest('resources/assets/js/'));

    // datatables
    var datatables_path = 'vendor/bower_dl/datatables-plugins/integration/bootstrap/3/';

    gulp.src(datatables_path + 'dataTables.bootstrap.css')
        .pipe(rename('dataTables.bootstrap.less'))
        .pipe(gulp.dest('resources/assets/less/others/'));

    gulp.src(datatables_path + 'dataTables.bootstrap.js')
        .pipe(gulp.dest('resources/assets/js/'));
});

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function(mix) {

    // merge scripts
    mix.scripts(['js/jquery.js',
            'js/bootstrap.js',
            'js/jquery.dataTables.js',
            'js/dataTables.bootstrap.js'],
        'public/assets/js/admin.js',
        'resources/assets'
    );

    // compile less
    mix.less('admin.less', 'public/assets/css/admin.css');
    // mix.sass('app.scss');
});
